<?php 

$uploaddir = $svrRoot."uploads/"; 
if(!is_writeable($uploaddir)) { ?>
	<fieldset class="myfieldset">
		<legend>Error</legend>
		Your uploads directory:<br /><br /><strong><i><?=$uploaddir;?></i></strong><br /><br />
		is not writable.  You cannot upload until this directory is writable.<br /><br />		
	</fieldset><br />
<?php  
		die(); 
} 

if($_FILES) { 
	$goto = $self; 
	//do upload
	foreach($_FILES['upload']['name'] as $k=>$v) { 
		$fname = basename(stripslashes($_FILES['upload']['name'][$k]));
		$uploadfile = $uploaddir.$fname; 
		$ftype 	= $_FILES['upload'][$k];
		if(stristr($ftype,"php") || stristr($ftype,"asp") || stristr($ftype,"pl")) { 
			echo "Problem uploading your attachment!\nError: Your attachment was not accepted because it appears 
			to be an invalid file type.  The file type was: ".$ftype."<br /><br />Use the upload files dialog 
			if you feel this is an error.\n";
			exit;				
		}
	
		if (move_uploaded_file($_FILES['upload']['tmp_name'][$k], $uploadfile)) {
			$fsize	= $_FILES['upload']['size'][$k];	   
		} elseif($_FILES['upload']['error'][$k]=="1") {
		   echo "Problem uploading your attachment!\n";
		   echo "Error: ";	   
		   echo "Your attachment is too large for the system! Max file size is 2 megabytes.\n";
		   exit;	
		} elseif($_FILES['upload']['error'][$k]=="2") {
		   echo "Problem uploading your attachment!\n";
		   echo "Error: ";	
		   echo "Your attachment is too large for this script! Max file size is 2 megabytes.\n";
		   exit;
		} elseif($_FILES['upload']['error'][$k]=="3") {
		   echo "Problem uploading your attachment!\n";
		   echo "Error: ";	
		   echo "No file was only partially uploaded.  Try again.\n";
		   exit;
		} elseif($_FILES['upload']['error'][$k]=="4") {
		   echo "Problem uploading your attachment!\n";
		   echo "Error: ";	
		   echo "No file was specified.\n";
		   exit;	   
		} else {
		   echo "Unknown problem uploading your attachment!\n";
		   //if($DEBUG) { 
		   echo "Upload: ".$uploadfile."<br /><br />";
		   echo "Debugging info:\n<pre>"; print_r($_FILES); echo "</pre>\n"; 
		   exit;
		  //} 
		 }
		unset($goto); 
		$goto = $self."?op=upload&message=success"; 
		header("Location: ".$goto); 
		exit;
	}
	header("Location: ".$goto); 
	exit;
} else { 

	if($_GET['message'] && $_GET['message'] == "success") { echo "<div class=\"message\">Operation completed successfully!</div><br />\n"; }
?>
	<form action="<?=$self;?>" method="post" name="myform" enctype="multipart/form-data">
	<input type="hidden" name="op" value="upload" />
	<fieldset class="myfieldset">
		<legend>Upload Files</legend>
	    <input type="hidden" name="MAX_FILE_SIZE" value="20480000" />
		<input type="file" name="upload[]" size="50" class="text_input" /><br />
		<div id="moreuploads"></div> 
		Allowed Filetypes: <acronym title="JPEG Image">JPG</acronym>, <acronym title="GIF Image">GIF</acronym>, <acronym title="Bitmap Image">BMP</acronym>, <acronym title="Portable Network Graphics">PNG</acronym></small>
	<br /><br />
	<span id="morelink">[<a href="javascript:moreUploads();">Upload More Files</a>]</span>
	</fieldset>
	<br /><br />
	<input type="submit" name="Upload" class="button" value="Upload File(s)" />&nbsp;&nbsp;
	<input type="button" name="cancel" class="button" value="<?=$Lang['noCancel'];?>" onclick="location.href='?'" />&nbsp;&nbsp;
	<br />
	</form>
	<br /><br />
	<fieldset class="myfieldset">
		<legend><a href="javascript:showUploads('0');">Review Uploads</a></legend>
		<div id="uploadfieldset"></div>
	</fieldset>
<?php } ?>